var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
/**
 * 类类型 + 继承接口 + 混合类型 + 接口继承类
 * implements: extends 是继承父类，只要那个类不是声明final或者定义为abstract就能继承,JAVA中不支持多重继承，继承只能继承一个类，但implements可以实现多个接口，用逗号分开就行了。
 * */
/*接口继承类*/
var Control = /** @class */ (function () {
    function Control() {
    }
    return Control;
}());
var Button = /** @class */ (function (_super) {
    __extends(Button, _super);
    function Button() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    Button.prototype.select = function () {
    };
    return Button;
}(Control));
var TextBox = /** @class */ (function (_super) {
    __extends(TextBox, _super);
    function TextBox() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    TextBox.prototype.select = function () { };
    return TextBox;
}(Control));
var ImageC = /** @class */ (function () {
    function ImageC() {
    }
    ImageC.prototype.select = function () {
    };
    return ImageC;
}());
function getCounter() {
    var counter = (function (start) { });
    counter.interval = 10;
    counter.reset = function () { };
    return counter;
}
var c = getCounter();
c(10);
var square = {};
square.color = 'yellow';
square.penWidth = 10;
square.sideLength = 30;
//工厂方法
function createClock(ctro, hour, minute) {
    return new ctro(hour, minute);
}
var DigitalClock = /** @class */ (function () {
    function DigitalClock(h, m) {
    }
    DigitalClock.prototype.tick = function () {
        console.log('beep beep');
    };
    return DigitalClock;
}());
var AnalogClock = /** @class */ (function () {
    function AnalogClock(h, m) {
    }
    AnalogClock.prototype.tick = function () {
        console.log('tick toc');
    };
    return AnalogClock;
}());
var digital = createClock(DigitalClock, 12, 13);
var analog = createClock(AnalogClock, 14, 15);
console.log(digital);
var Clock = /** @class */ (function () {
    function Clock(h, m) {
    }
    Clock.prototype.setTime = function (d) {
        this.currentTime = d;
    };
    return Clock;
}());
var myOnly = ['hardy', '小方块'];
// myOnly[2] = 'hhardyy';
// -----------------------------------------------------
var Animal = /** @class */ (function () {
    function Animal() {
    }
    return Animal;
}());
var Dog = /** @class */ (function (_super) {
    __extends(Dog, _super);
    function Dog() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    return Dog;
}(Animal));
var myArray = ['hardy', '小方块'];
var mystr = myArray[0];
/* function(source:string,subString:string)
* 中的source和subString名字可以和接口的不一样，但是类型要一样，
* 只需要实现的规则和接口定义的规则一样就好了
* */
var mySearch = function (source, subString) {
    var result = source.search(subString);
    return result > -1;
};
console.log(mySearch('https:hhardyy.com', 'hhardyy'));
/**
 * 可选属性 + 只读属性
 * ? = 可选，可有可没有
 * readonly = 只读
 * */
/*数组只读*/
var arr = [2, 3, 4, 5];
var pont = { x: 1, y: 2 };
function createCricle(config) {
    var newSquare = { color: 'red', area: 100 };
    newSquare.color = config.color ? config.color : newSquare.color;
    newSquare.area = config.width ? config.width * config.width : newSquare.area;
    return newSquare;
}
var mySquare = { color: 'green', width: 200 };
var newSquare = createCricle(mySquare);
function printLabel(labelledObj) {
    console.log(labelledObj.label);
}
var myObj = { size: 10, label: 'Size 10 Object' };
printLabel(myObj);
